package com.youyi.yyviewsdklibrary.View;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lkx.liandianqinew.R;

public class MyTitleView extends LinearLayout {
    private ImageView mLine;
    private TextView mTitle;

    public MyTitleView(Context context) {
        super(context);
    }

    public MyTitleView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.MyTitleView);
        String string = obtainStyledAttributes.getString(R.styleable.MyTitleView_title_text);
        int color = obtainStyledAttributes.getColor(R.styleable.MyTitleView_title_color, -16777216);
        int color2 = obtainStyledAttributes.getColor(R.styleable.MyTitleView_line_color, context.getResources().getColor(R.color.colorAccent));
        View inflate = LayoutInflater.from(context).inflate(R.layout.view_line_title, (ViewGroup) this, true);
        this.mTitle = (TextView) inflate.findViewById(R.id.id_ll_title);
        ImageView imageView = (ImageView) inflate.findViewById(R.id.id_ll_view);
        this.mLine = imageView;
        try {
            imageView.setColorFilter(color2);
        } catch (Exception e) {
            e.printStackTrace();
            this.mLine.setBackgroundColor(color2);
        }
        this.mTitle.setTextColor(color);
        this.mTitle.setText(string);
    }

    public void setTitle(String str) {
        TextView textView = this.mTitle;
        if (textView != null) {
            textView.setText(str);
        }
    }
}
